﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Windows.Forms;
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
namespace ChanTaiApi
{
    static class Program
    {
        private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                Application.ThreadException += Application_ThreadException;
                if (Environment.UserInteractive)
                {
                   MainForm f = new MainForm();
                    f.ShowDialog();
                    return;
                }

                // 作为服务启动
                ServiceBase.Run(new ServiceBase[] { new Service() });
            }
            catch (Exception e)
            {
                Log.ErrorFormat("应用程序发生异常{0}", e);
            }
        }
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Log.ErrorFormat("应用程序发生异常{0}", e.Exception);
        }
    }
}
